package com.sunlands.zlcx.usercenter.vo.count;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.sunlands.zlcx.usercenter.serialize.DoubleSerialize;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Objects;

/**
 * @author anjunling
 * @create 2020/7/28 13:59
 */
@Data
@Builder
@NoArgsConstructor
public class LearnTimeOverView implements Serializable {
    private static final long serialVersionUID = 7366909785417676451L;

    @ApiModelProperty(value = "专注次数")
    private Long times;

    @ApiModelProperty(value = "专注时长")
    private Long duration;

    @ApiModelProperty(value = "平均时长")
    @JsonSerialize(using = DoubleSerialize.class)
    private Double avg;

    public LearnTimeOverView(Long times, Long duration, Double avg) {
        this.times = Objects.isNull(times) ? 0L : times;
        this.duration = Objects.isNull(duration) ? 0L : duration;
        this.avg = Objects.isNull(avg) ? 0 : avg;
    }
}
